 model{
	for(i in 1:N) { ##observation
		##form the linear predictor (No intercept and constrained Thresholds)
		mu[i] <- 	x[i]*beta +  ##SPII
		##			x[i,2]*beta[2] +  ##caps
		##			x[i,3]*beta[3] +  ##Majpow
		##			x[i,4]*beta[4] +  ##Threat
		##			x[i,5]*beta[5] +  ##Mids
		##			x[i,6]*beta[6] +  ##Counter				
					alpha1[namehigh[i]] -	 ##Random Effect for Dem
					alpha2[namelow[i]]		 ##Random Effect for Non-Dem
 		##Cum. Logistic Probs.
		logit(Q[i,1]) <- tau[1] -mu[i] #tau[1] is negative
		p[i,1] <- Q[i,1]
		logit(Q[i,2]) <- tau[2] -mu[i] #tau[2] is positive
		##slice cdf
		p[i,2] <- Q[i,2]-Q[i,1]			
	
		p[i,3] <- 1-Q[i,2]
		y[i] ~ dcat(p[i,1:3])## p[i,] sums to 1 for each i
	}
	## Random Effects
	for(p1 in 1:J1) {
	alpha1[p1] ~ dnorm(mu1,prec1)
	}
	for(p2 in 1:J2) {
	alpha2[p2] ~ dnorm(mu2,prec2)
	}
	##Priors over random effects
	mu1 ~ dnorm(0,.0001)
	mu2 ~ dnorm(0,.0001)
    prec1 <- pow(sigtemp1, -2)
	prec2 <- pow(sigtemp2, -2)
	sigtemp1 ~ dunif(0,10)
	sigtemp2 ~ dunif(0,10)

	##priors over beta
	beta ~ dnorm(b0[],B0[])
	
	##prior for threshold
		tau0 ~ dnorm(0,.01)	
		
	##Sort thresholds incase tau0 is negative
		tau[1] <- step(tau0)* -tau0 + step(-tau0)*tau0
		tau[2] <- step(tau0)* tau0 + step(-tau0)*-tau0

}


